package com.hxexp.weixin.test;

import java.util.HashMap;
import java.util.Map;

import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

import com.hxexp.weixin.common.cache.PassengerTicketCacheManager;
import com.hxexp.weixin.test.runner.JUnit4WithSpringLogClassRunner;

/**
 * 乘客已购车票缓存管理器测试
 *
 * @author wang.bin
 *
 */
@RunWith(JUnit4WithSpringLogClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@ContextConfiguration(locations = { "classpath:conf/spring/spring-biz.xml", "classpath:conf/spring/spring-ehcache.xml" })
public class PassengerTicketCacheManagerTester {

    @Autowired
    private PassengerTicketCacheManager passengerTicketCache;

    private static String key = "1";
    private static String orderId = "001";
    private static String key1 = "2";
    private static String orderId1 = "002";
    private static Map<String, String> map = new HashMap<String, String>();

    @Test
    public void testCase01() {
        passengerTicketCache.put(key, orderId);
    }

    @Test
    public void testCase02() {
        map.put(key, orderId);
        map.put(key1, orderId1);
        passengerTicketCache.batchPut(map);
    }

    @Test
    public void testCase03() {
        String returnValue = passengerTicketCache.get(key);
        Assert.assertEquals(orderId, returnValue);
    }

    @Test
    public void testCase04() {
        passengerTicketCache.evict(key);
        String returnValue = passengerTicketCache.get(key);
        Assert.assertEquals(null, returnValue);
    }
}
